using UnityEngine;
using System.Collections;

public class HeroControl : MonoBehaviour 
{

	public float speed = 25.0f;
	
	private bool isMoving = true;
	
	void Start () 
	{
	
	}
	
	void Update () 
	{
		if(isMoving)
		{
			gameObject.transform.Translate(0.0f, 0.0f, speed*Time.deltaTime*Input.GetAxis("Vertical"));
			gameObject.transform.Translate(speed*Time.deltaTime*Input.GetAxis("Horizontal"), 0.0f, 0.0f);
		}
		if((isMoving) && (Input.GetMouseButtonDown(0)))
		{
			foreach(Transform child in gameObject.transform)
				child.rigidbody.isKinematic = false;
			foreach(Transform child in gameObject.transform)
				child.rigidbody.AddExplosionForce(100.0f, new Vector3(4.0f, 4.0f, 4.0f) + gameObject.transform.position, 10.0f);
			isMoving = false;
		}
		
	}
	
	/*
	void OnGUI()
	{
		
		if(GUI.Button(new Rect(10, 10, 300, 300), "press"))
		{
			Application.LoadLevel(Application.loadedLevel);
		}
	}
	*/
}
